﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cAlgo.Export
{
    public class Sqlexport
    {
        private TradingDataContext context;

        Sqlexport()
        {
            context = new TradingDataContext();            
        }

        public void InsertTick(decimal ask, decimal bid, String code, short digits, decimal pipSize, decimal pointSize, decimal spread, DateTime timestamp)
        {
            Task.Factory.StartNew(() =>
                {
                    SymbolSet tick = new SymbolSet();

                    tick.Ask = ask;
                    tick.Bid = bid;
                    tick.Code = code;
                    tick.Digits = digits;
                    tick.PipSize = pipSize;
                    tick.PointSize = pointSize;
                    tick.Spread = spread;
                    tick.Timestamp = timestamp;

                    context.SymbolSet.InsertOnSubmit(tick);

                    context.SubmitChanges();
                });
        }
    }
}
